package com.example.mediastore.application;

import android.app.Application;

import androidx.room.Room;


import com.example.mediastore.bean.FileBean;
import com.example.mediastore.database.FileDataBase;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class MyApplication extends Application {


    private static MyApplication myApplication;

    //声明一个数据库对象
    private FileDataBase fileDataBase;

    //声明一个路径
    private final ConcurrentHashMap<String, List<FileBean>> hashMap = new ConcurrentHashMap<>();



    //创建一个单例
    public static MyApplication getInstance(){
        return myApplication;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        myApplication = this;
        fileDataBase = Room.databaseBuilder(this, FileDataBase.class, "file")
                .build();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    public FileDataBase getFileDataBase() {
        return fileDataBase;
    }

    public ConcurrentHashMap<String, List<FileBean>> getHashMap() {
        return hashMap;
    }
}
